<?php
require_once 'forms/UsuarioForm.php';
require_once 'repository/UsuarioRepository.php';

class UsuarioController extends Zend_Controller_Action
{

    public function novoAction()
    {
        $form = new UsuarioForm();
        $repository = new UsuarioRepository();
        if($this->getRequest()->isPost()){
            if($form->isValid($this->getRequest()->getPost())){
                $form->getElement('usu_senha')->setValue(sha1($form->getValue('usu_senha')));
                $repository->inserir($form->getValues());
                $this->view->mensagem = "Dados inseridos com sucesso";
            }else{
                $this->view->mensagem = "Ocorreram erros";
            }
        }
        $this->view->form = $form;
    }

}

